home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / kernel / raid / devPrint.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-19  |  7.4 KB  |  286 lines

  1. /* 
  2.  * devPrint.c --
  3.  *
  4.  *    Routines for printing out various RAID related data structures.
  5.  *
  6.  * Copyright 1989 Regents of the University of California
  7.  * All rights reserved.
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  */
  16.  
  17. #ifndef lint
  18. static char rcsid[] = "$Header: /cdrom/src/kernel/Cvsroot/kernel/raid/devPrint.c,v 1.7 92/06/25 17:20:50 eklee Exp $ SPRITE (Berkeley)";
  19. #endif /* not lint */
  20.  
  21. #include "sync.h"
  22. #include <sprite.h>
  23. #include <stdio.h>
  24. #include <assert.h>
  25. #include "fs.h"
  26. #include "devBlockDevice.h"
  27. #include "devRaid.h"
  28. #include "devRaidUtil.h"
  29. #include "schedule.h"
  30.  
  31.  
  32. /*
  33.  *----------------------------------------------------------------------
  34.  *
  35.  * PrintRequests --
  36.  *
  37.  * Results:
  38.  *    None.
  39.  *
  40.  * Side effects:
  41.  *    Prints to stdout.
  42.  *
  43.  *----------------------------------------------------------------------
  44.  */
  45.  
  46. #define MAX_ROW        2
  47. #define MAX_COL        4
  48. #define MAX_SECTORS    4
  49.  
  50.  
  51. void
  52. NPrint(string, n)
  53.     char    *string;
  54.     int        n;
  55. {
  56.     int        i;
  57.     for (i = 0; i < n; i++) {
  58.     printf("%s", string);
  59.     }
  60. }
  61.  
  62. #ifdef TESTING
  63. void
  64. PrintRequests(reqControlPtr)
  65.     RaidRequestControl  *reqControlPtr;
  66. {
  67.     RaidBlockRequest    *reqPtr;
  68.     int            col, row, sector;
  69.     int            i, j;
  70.     extern Raid        *raidPtr;
  71.     static char        outputBuf[MAX_COL][MAX_ROW][MAX_SECTORS];            
  72.  
  73.     assert(raidPtr->numCol <= MAX_COL && raidPtr->numRow <= MAX_ROW &&
  74.         raidPtr->sectorsPerDisk <= MAX_SECTORS);
  75.  
  76.     bzero((char *) outputBuf, sizeof(outputBuf));
  77.     for ( i = 0; i < reqControlPtr->numReq; i++ ) {
  78.     reqPtr = &reqControlPtr->reqPtr[i];
  79.     if (reqPtr->state == REQ_READY) {
  80.         int        startSector, numSector;
  81.         startSector = ByteToSector(raidPtr, reqPtr->devReq.startAddress);
  82.         numSector   = ByteToSector(raidPtr, reqPtr->devReq.bufferLen);
  83.         for (j = 0; j < numSector; j++) {
  84.         outputBuf[reqPtr->col][reqPtr->row][startSector+j] =
  85.             (reqPtr->devReq.operation == FS_READ ? 'r' : 'w');
  86.         }
  87.     }
  88.     }
  89.     for (row = 0; row < raidPtr->numRow; row++) {
  90.     printf("+");
  91.     NPrint("-", raidPtr->numCol);
  92.     printf("+\n");
  93.     for (sector = 0; sector < raidPtr->sectorsPerDisk; sector++) {
  94.         printf("%c", '|');
  95.         for (col = 0; col < raidPtr->numCol; col++) {
  96.         printf("%c", (outputBuf[col][row][sector] ?
  97.             outputBuf[col][row][sector] : ' '));
  98.         }
  99.         printf("%c\n", '|');
  100.     }
  101.     }
  102. }
  103. #endif TESTING
  104.  
  105.  
  106. /*
  107.  *----------------------------------------------------------------------
  108.  *
  109.  * PrintHandle --
  110.  *
  111.  *    Print DevBlockDeviceHandle.
  112.  *
  113.  * Results:
  114.  *    None.
  115.  *
  116.  * Side effects:
  117.  *    Prints to stdout.
  118.  *
  119.  *----------------------------------------------------------------------
  120.  */
  121.  
  122. void
  123. PrintHandle(handlePtr)
  124.     DevBlockDeviceHandle  *handlePtr; /* Handle pointer of device. */
  125. {
  126.     printf("DevBlockDeviceHandle %x:\n", handlePtr);
  127.     printf("    blockIOProc  : %x\n", handlePtr->blockIOProc);
  128.     printf("    IOControlProc: %x\n", handlePtr->IOControlProc);
  129.     printf("    releaseProc  : %x\n", handlePtr->releaseProc);
  130.     printf("    minTransferUnit: %x\n", handlePtr->minTransferUnit);
  131.     printf("    maxTransferSize: %x\n", handlePtr->maxTransferSize);
  132.     printf("    clientData: %x\n", handlePtr->clientData);
  133. }
  134.  
  135.  
  136. /*
  137.  *----------------------------------------------------------------------
  138.  *
  139.  * PrintDevice --
  140.  *
  141.  *    Print Fs_Device.
  142.  *
  143.  * Results:
  144.  *    None.
  145.  *
  146.  * Side effects:
  147.  *    Prints to stdout.
  148.  *
  149.  *----------------------------------------------------------------------
  150.  */
  151.  
  152. void
  153. PrintDevice(devicePtr)
  154.     Fs_Device  *devicePtr; /* Handle pointer of device. */
  155. {
  156.     printf("Device %u %02u\n", devicePtr->type, devicePtr->unit);
  157. /*
  158.     printf("Device %x:\n", devicePtr);
  159.     printf("    type: %d  unit: %02u\n", devicePtr->type, devicePtr->unit);
  160. */
  161. }
  162.  
  163.  
  164. /*
  165.  *----------------------------------------------------------------------
  166.  *
  167.  * PrintRequest --
  168.  *
  169.  *    Print DevBlockDeviceRequest.
  170.  *
  171.  * Results:
  172.  *    None.
  173.  *
  174.  * Side effects:
  175.  *    Prints to stdout.
  176.  *
  177.  *----------------------------------------------------------------------
  178.  */
  179.  
  180. void
  181. PrintRequest(requestPtr)
  182.     DevBlockDeviceRequest *requestPtr; /* IO Request to be performed. */
  183. {
  184.     char *opStr;
  185.  
  186.     opStr = (requestPtr->operation == FS_READ ? "READ": "WRITE");
  187.  
  188.     printf("Block Request %s %x %x:\n", opStr, requestPtr->startAddress,
  189.         requestPtr->bufferLen);
  190. /*
  191.     printf("Block Request %x:\n", requestPtr);
  192.     printf("    operation: %s\n", (requestPtr->operation == FS_READ ?
  193.                                 "READ": "WRITE") );
  194.     printf("    startAddrHigh: %x\n", requestPtr->startAddrHigh);
  195.     printf("    startAddress : %x\n", requestPtr->startAddress);
  196.     printf("    bufferLen    : %x\n", requestPtr->bufferLen);
  197.     printf("    buffer: %x %40s\n", requestPtr->buffer, requestPtr->buffer);
  198.     printf("    doneProc  : %x\n", requestPtr->doneProc);
  199.     printf("    clientData: %x\n", requestPtr->clientData);
  200. */
  201. }
  202.  
  203.  
  204. /*
  205.  *----------------------------------------------------------------------
  206.  *
  207.  * PrintRaid --
  208.  *
  209.  *    Print Raid.
  210.  *
  211.  * Results:
  212.  *    None.
  213.  *
  214.  * Side effects:
  215.  *    Prints to stdout.
  216.  *
  217.  *----------------------------------------------------------------------
  218.  */
  219.  
  220. void
  221. PrintRaid(raidPtr)
  222.     Raid *raidPtr;
  223. {
  224.     int         col, row;
  225.     RaidDisk    *diskPtr;
  226.  
  227.     printf("RAID=================================================\n");
  228.     printf("    state %d\n", raidPtr->state);
  229.     PrintDevice(raidPtr->devicePtr);
  230.     printf("    numRow %d\n", raidPtr->numRow);
  231.     printf("    numCol %d\n", raidPtr->numCol);
  232.     printf("    numSector %u\n", raidPtr->numSector);
  233.     printf("    numStripe %u\n", raidPtr->numStripe);
  234.     printf("    dataSectorsPerStripe %u\n",raidPtr->dataSectorsPerStripe);
  235.     printf("    sectorsPerDisk %u\n",raidPtr->sectorsPerDisk);
  236.     printf("    bytesPerStripeUnit %u\n",raidPtr->bytesPerStripeUnit);
  237.     printf("    dataBytesPerStripe %u\n",raidPtr->dataBytesPerStripe);
  238.     printf("    numDataCol %d\n", raidPtr->numDataCol);
  239.     printf("    logBytesPerSector %d\n", raidPtr->logBytesPerSector);
  240.     printf("    sectorsPerStripeUnit %d\n", raidPtr->sectorsPerStripeUnit);
  241.     printf("    rowsPerGroup %d\n", raidPtr->rowsPerGroup);
  242.     printf("    stripeUnitsPerDisk %d\n", raidPtr->stripeUnitsPerDisk);
  243.     printf("    groupsPerArray %d\n", raidPtr->groupsPerArray);
  244.     printf("    parityConfig %c\n", raidPtr->parityConfig);
  245.     if (raidPtr->disk != NULL) {
  246.     for ( row = 0; row < raidPtr->numRow; row++ ) {
  247.         for ( col = 0; col < raidPtr->numCol; col++ ) {
  248.         diskPtr = raidPtr->disk[col][row];
  249.         if (diskPtr != (RaidDisk *) NIL) {
  250.             printf("Disk: %d %d %d  state: %d  numValidSector: %d\n",
  251.                 row, col, diskPtr->version,
  252.                 diskPtr->state, diskPtr->numValidSector);
  253.             PrintDevice(&diskPtr->device);
  254.         }
  255.         }
  256.     }
  257.     }
  258.     printf("LogDisk: offset=%d\n", raidPtr->log.logDevOffset);
  259.     printf("LogDisk: endOffset=%d\n", raidPtr->log.logDevEndOffset);
  260.     PrintDevice(&raidPtr->log.logDev);
  261.     printf("=====================================================\n");
  262. }
  263.  
  264.  
  265. /*
  266.  *----------------------------------------------------------------------
  267.  *
  268.  * PrintTime --
  269.  *
  270.  *    Print current time.
  271.  *
  272.  * Results:
  273.  *    None.
  274.  *
  275.  * Side effects:
  276.  *    Prints to stdout.
  277.  *
  278.  *----------------------------------------------------------------------
  279.  */
  280.  
  281. void
  282. PrintTime()
  283. {
  284.     printf("TIME: %lg\n", LocalTime());
  285. }
  286.